#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>

int main()
{
	pid_t my_pid,parent_pid;
	uid_t my_uid,my_euid;
	gid_t my_gid,my_egid;
	struct passwd *my_info;

	my_pid=getpid();
	parent_pid=getppid();
	my_uid=getuid();
	my_euid=geteuid();
	my_gid=getgid();
	my_egid=getegid();
	my_info=getpwuid(my_uid);

	printf("My PID:%ld\n",my_pid);
	printf("Parent PID:%ld\n",parent_pid);
	printf("User Id:%ld\n",my_uid);
	printf("Effective User Id:%ld\n",my_euid);
	printf("Group Id:%ld\n",my_gid);
	printf("Effective Group Id:%ld\n",my_egid);

	if(my_info) {
		printf("Login Name:%s\n",my_info->pw_name);
		printf("Passwd:%s\n",my_info->pw_passwd);
		printf("My UserId:%ld\n",my_info->pw_uid);
		printf("My GroupId:%ld\n",my_info->pw_gid);
		printf("My real name:%s\n",my_info->pw_gecos);
		printf("My home dir:%s\n",my_info->pw_dir);
		printf("My work shell:%s\n",my_info->pw_shell);
	}

	return 0;
}
